package spring.core.examples.xml;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
 * Demonstrates a been that uses automatic wiring for bean construction.
 */
public class AutowiredCouple {

	/** The spouse a. */
	private Person spouseA;

	/** The spouse b. */
	private Person spouseB;

	/**
	 * Instantiates a new autowired couple.
	 */
	public AutowiredCouple() {
		super();
	}

	/**
	 * Instantiates a new couple using auto wiring. Not that the beans name is
	 * used as default qualifier.
	 * 
	 * @param spouseA
	 *            the spouse a
	 * @param spouseB
	 *            the spouse b
	 */
	@Autowired
	public AutowiredCouple(@Qualifier("harry") Person spouseA,
			@Qualifier("elke") Person spouseB) {
		super();
		this.setSpouseA(spouseA);
		this.setSpouseB(spouseB);
	}

	/**
	 * Gets the spouse a.
	 * 
	 * @return the spouse a
	 */
	public Person getSpouseA() {
		return spouseA;
	}

	/**
	 * Gets the spouse b.
	 * 
	 * @return the spouse b
	 */
	public Person getSpouseB() {
		return spouseB;
	}

	/**
	 * Sets the spouse a.
	 * 
	 * @param spouseA
	 *            the new spouse a
	 */
	public void setSpouseA(Person spouseA) {
		this.spouseA = spouseA;
	}

	/**
	 * Sets the spouse b.
	 * 
	 * @param spouseB
	 *            the new spouse b
	 */
	public void setSpouseB(Person spouseB) {
		this.spouseB = spouseB;
	}

	/**
	 * To string.
	 * 
	 * @return the string
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return this.getClass().getSimpleName() + " (" + this.getSpouseA()
				+ ", " + this.getSpouseB() + ")";
	}

}
